It's good to stay active (vs) To stay active is good.
Yes, they tell us the same thing. The former is just an extraposed infinitive clause, which is generally more common in spoken English than written English. The latter is not common, but it's perfectly grammatical.
The it is just a dummy subject used as a placeholder to fill the empty slot in the subject position when the infinitival clause is extraposed to the final position.
1 [To stay active] is good
2 __ is good [to stay active]
3 (It) is good [to stay active]
You need to have any hobby. It's good to stay active.
This is not really coherent to me, because it is inexactly related. It might be better if you combine them in a same sentence.
You need to have a hobby because it's good to stay active.
Note that any cannot be used in a positive declarative sentence. We use some hobbies or just a hobby.