The economical viewpoint is in principle on the shoulders of the Product Owner (PO), who is interested in maximising the value that is delivered, and is business savvy. He/she does so by proritizing the product backlog items.
The Development Team is committed to deliver working software and implement product backlog items negotiated in the sprint planning meetings. Whether this requires rewriting or refactoring is a technical decision that belongs to the team. There must be trust that the team is doing the best choice, and there can't be PO interference on technical decisions without the risk of breaking an efficient team dynamic.
Now, if the team would decide to rewrite major parts with the consequence of slowing down the delivery pipeline over a longer period, it would certainly not be for fancy reasons. It might be a necessary investment.
However, as this would impact the burndown rate and thus the sprint planning over a longer period, this should be discussed and agreed with the PO by clarifying what's at stake, and giving predictability.
The controversial use of developer stories can help to keep visibity on such technical tasks, but these shall be used in the sprint backlog and shall not polute the product backlog, if they don't bring additional value to the users.
It could be also be that the adoption of a new framework could significantly improve (or even enable) existing user stories, in which case it would be something that matters to PO as well and would so indirectly appear in the product backlog.
Attention: the thought that DT could start turning wild and is not committed to the product delivery bears the risk of breaking a fundamental trust. This might undermine the effectiveness of the agile approach, and in the worst case evolve into a self-fulfilling prophecy (e.g. DT starts to hide these technical aspects to PO fearing misunderstanding, and the PO only observing an unexplainable measurable decrease in performance, creating doubt and suspicion, which decreases DT motivation and increase turnover, etc.).