Kathryn Smith, 23, had a history of self-harm, substance abuse and mental health issues and her pregnancy was not planned, Birmingham Crown Court heard.
Ayeeshia Jane Smith died at her home in Burton-upon-Trent, Staffordshire, when her heart was torn by a forceful stamp, a jury was told.
Ms Smith and her partner Matthew Rigby, 22, both from Nottingham, deny murder.
Ms Smith was nearly three months pregnant with Ayeeshia when midwife Hilary Sayles found her living in her father's garage in Overseal in Derbyshire, the court heard.
Ms Sayles said: "There was a bed and furniture, but it was clearly unsuitable for a new baby - or anybody."
Social services moved the expectant mother into supported housing in nearby Swadlincote the next day.
Ms Sayles said: "She said she had been adopted, and I had concerns about her history of self-harm and mental health issues and also the fact she had had substance abuse."
She added: "I didn't know what she'd had in terms of parenting, because she'd been adopted - at what stage I didn't know - but also, as an unplanned pregnancy, whether she would be able to put the needs of her child before her own."
Two weeks before Ayeeshia died, Derbyshire County Council social workers went to her home after a report Ms Smith had been "under the influence of a substance".
Care support worker Angela Moseley told the jury she thought she could smell cannabis in the flat and asked Ms Smith to do an on-the-spot drug test, but the mother refused.
Ms Smith, of Sandfield Road, Nottingham, and Mr Rigby, of Sloan Drive, Nottingham, have also pleaded not guilty to allowing or causing a child's death and child cruelty.
The trial continues.
A mother accused of murdering her 21-month-old daughter lived in a garage while pregnant, a midwife told a court.