The Glasgow performer was paid for a campaign to encourage face coverings and lateral flow testing.
She admitted the tweets, from a number of years ago, had "terrible, horrific undertones" after they were published by several newspapers.
A Scottish government spokesperson said trust in its public health messages was "paramount".
Ms Godley, 60, gained a large online following for her viral voice-overs of First Minister Nicola Sturgeon's daily briefings during the lockdowns.
She has apologised "without reservation" to "everyone I hurt" and offered to donate the fee for the advert to the STV Children's Appeal.
A number of posts, the most recent of which was from 2017, were highlighted by the Scottish Sun.
The Daily Beast followed up by publishing several tweets from 2011 and 2012 about black performers.
In a statement, Ms Godley said: "There are tweets from my past social media that are horridly offensive, I believe in progress not perfection and I am far from perfect.
"People have every right to go through my social media and see what values I hold and to find hurtful phrases and statements is shocking, I am deeply sorry to everyone I offended.
"Comedy is no excuse to use disgusting and hurtful words that affect people and I know many of you expected better of me. I apologise for every single word that upset people."
Ms Godley's #StopTheSpike adverts ran on TV and social media. She previously appeared in government-funded Zero Waste Scotland promotions.
A Scottish government spokesperson said: "A series of unacceptable tweets by Janey Godley have been brought to our attention and, while she has rightly apologised, trust in our public health messages at this time is paramount.
"We have therefore taken the decision to withdraw any further campaign material in which Ms Godley features.
"The material will be discontinued immediately on our own channels and withdrawn as soon as possible from external media."
Ms Godley was brought up in the east end of Glasgow, and has spoken candidly of her traumatic early life which included poverty and sexual abuse, before beginning a comedy career later in life.
She has appeared on the BBC as panellist on shows such as BBC Radio Scotland's Breaking the News and BBC One's Have I Got News for You, and as an actor in Traces.
She has also performed with The National Theatre of Scotland and was a regular at the Edinburgh Fringe.
High profile comedians, including David Baddiel and Dawn French, offered their support on Twitter on Wednesday and Aberdeen Performing Arts stood by their decision to cast her in their pantomime Beauty and the Beast this winter.
On Thursday, following the Daily Beast article, Ms Godley tweeted: "I am not asking people who like me to defend the offensive things I said, I appreciate many people who enjoy my work are horrified and upset at my tweets, that's how it should be, I am not the victim here, the people I hurt and offended are and I take that responsibility."