This quote comes from Act III scene 4, when Lear, Kent, the Fool and Edgar are on the Heath and Edgar is discovered in the hovel where they hope to take shelter. What is important to realise is that a bit before this quote, when they find this shelter, Lear says to Kent, then the Fool, that they should go in and take shelter but he will wait till after he first prays as the storm distracts him from thinking about things that would be immensely more painful for him to think about:
Good my lord, enter here.
Prithee, go in thyself: seek thine own ease:
This tempest will not give me leave to ponder
On things would hurt me more. But I'll go in.
To the Fool
In, boy; go first. You houseless poverty,--
Nay, get thee in. I'll pray, and then I'll sleep.
Lear has clearly already disassociated from the fate that has led him to wander like a vagabond in his own Kingdom, and he indicates as much when he speaks about the poor homeless people who have no shelter at all.
How shall your houseless heads and unfed sides,
Your loop'd and window'd raggedness, defend you
From seasons such as these? O, I have ta'en
Too little care of this!
When Edgar, calling himself "Tom," is discovered, Lear sees him through his own universalized situation, asking Edgar questions that represent the questions he asks himself. This is why Lear asks Edgar if he gave everything to his two daughters only to be spurned and cast out of their houses. He universalizes his own regret and anger and sees Edgar as suffering the same shame that has happened to himself. Clearly the audience is presented with a figure who has lost his sanity.