I have a 7:30am flight out of T2 on a Thursday morning. I'm debating whether or not to stay the night somewhere the night before or just sleep in the airport because I am recommended to get there 3 hours before my departure.
I am a regular user of Heathrow. I typically aim to arrive 60--70 minutes before a flight if I have no bags and a boarding pass already, and 90--100 minutes on the rare occasion I have a bag to check, or if I need to talk to a check in person for some reason.
If you are new to the airport, maybe add thirty minutes to those times for some peace of mind. So, with a bag, you could aim to arrive at 5.30 am. (If you need to park or return a rental car, perhaps 15 minutes before that, as these can be quite confusing.) There is no reason to arrive 3 hours beforehand, the airport check in areas will not even be open at 4:30.
If you are travelling a long way to get to the airport, and you are concerned about getting lost, your car breaking down, or whatever, then you may be more comfortable with the three hour buffer, that is up to you. But it isn't required.
If you do want to stay nearby, the most convenient hotel for you is the Yotel at Heathrow Central. There is also a Sofitel attached to Terminal 5 and a Hilton Garden Inn near Hatton Cross tube station. Other hotels require a bus ride: local London red buses are free to pick up within the airport perimeter and accept contactless card payment on the way back, but they don't always go directly to/from the hotels; the "Heathrow Hoppa" [sic] is outrageously expensive at £5 per ride per person and should usually be avoided; taxis are very reluctant to do local jobs to/from the airport (although they can be cheaper than the Hoppa); and the non-London buses are cash-only and overpriced. In reality I don't think staying nearby saves much hassle over coming out from London, unless you are in one of the first three hotels I mentioned.