Hmmm.
Is this the family at 29 Wester Portsburgh, Edinburgh St Cuthberts in 1841, consisting of Daniel Gibson, 35, Anne Gibson, 30, Henry, Margaret, James, and Robert plus Mary Marshal, 40 and Alexander Marshal, 9? Are you looking at the original census, or at a transcription?
The census transcription (
http://www.freecen.org.uk/cgi/search.pl) says that Daniel, Henry and Mary were hawkers. This suggests to me that they were probably, as you say, fairly poor, and possibly illiterate, so it is very possible that they gave wrong information about their ages to the census enumerator. They could have been itinerant; many hawkers were.
If this is the right family, I see that most of the family were not born in Midlothian. Only Robert, aged 1, and Alexander Marshal, are listed as born in Midlothian.
In which parish did you find the burial record? How do you know for sure that it is your Anne Gibson? Again, are you looking at the original or at a transcription? If you are looking at the original, how are the names of other women recorded - in particular, are they listed as 'x or y' or are they all just listed with a single surname?
Does Margaret's marriage certificate specifically say that her father was alive in 1858, or does it just not say that he was deceased? Who does the marriage certificate say that her mother was? What was the religious denomination of the marriage?
The first line of enquiry should be to find out whether the records of Dalkeith poor house have survived, and if so to look up the records of Robert and James. If you are lucky and they have survived, they should tell you quite a lot about the family and their circumstances, and in particular where they came from.
I note with great interest the marriage of a Daniel Gibson to Ann Marshall in Forres, Moray, on 25 January 1820. Could Ann(e) Gibson have been Ann(e) Marshall, and could Mary Marshall be her sister or sister-in-law? Or is this a speculation too far?