It took her two hours to finish her homework.
It took two hours for her to finish her homework.
Q: I know #1 is correct and I guess #2 is also correct/natural. What is your opinion?
They're equally correct and natural. The difference between them is the subtle nuance of how much responsibility is attributed to her.
In the first one, "it took her two hours to do X", it sounds as though she's directly responsible for the amount of time that passed.
Here's a way to use that nuance for irony, in a case where the amount of time is your choice:
It took him two days to text me back! I guess my question scared him.
In the second version, "it took two hours for her to do X", you get the opposite nuance, a sense that there were factors beyond her control.
Here's a sentence where you'd use that, because there's clearly no responsibility implied:
It takes two years for a spaceship to travel to Mars. What a massive distance!
Finally, there's also a third version that seems to put the responsibility (or at least the cause) on the other party:
The homework took her two hours to do. I'm going to call her teacher and tell him it's too much.
It's important to note that in practice, people aren't excessively careful about which wording to use, and the focus of responsibility can easily be changed by intonation, emphasis, tone, and so on.