Sometimes in order to understand a particular verse or even a paragraph, or a chapter it is necessary to consult the Scriptures around those you need clarified. That is true of most of Matthew chapter 10, and it is also necessary in some cases to refer to similar scripture in other books of the Bible.
Here is a commentary by Albert Barnes on Matthew chapter 10:
Jesus calls, commissions, and names his twelve disciples, Matthew 10:1-4. Gives them
particular instructions relative to the objects of their ministry, Matthew 10:5, Matthew 10:6.
Mode of preaching, etc., Matthew 10:7-15. Foretells the afflictions and persecutions they
would have to endure, and the support they should receive, Matthew 10:16-25. Cautions them
against betraying his cause, in order to procure their personal safety, Matthew 10:26-39. And
gives especial promises to those who should assist his faithful servants in the execution of
their work, Matthew 10:40-42.
please note that he lumps verses 26 through 39 together, and says that he is cautioning them against betraying his cause in order to procure their personal safety.
So let's take a look at those Scriptures and see how they read in that regard.
All Scriptures are taken from the King James version of the Bible.
Matthew 10:26 Fear them not therefore: for there is nothing covered, that shall not be revealed; and hid, that shall not be known.
Here he is telling them that God knows everything that happens and one day it will be proclaimed to the world for the judgment.
Matthew 10:27 What I tell you in darkness, that speak ye in light: and what ye hear in the ear, that preach ye upon the housetops.
and in the verse you asked about he is telling them what I taught you alone out of the hearing of everyone else, you now pronounce to the world.
Matthew 10:28 And fear not them which kill the body, but are not able to kill the soul: but rather fear him which is able to destroy both soul and body in hell.
Here he is saying do not fail to preach the Gospel out of fear of men all they can do is kill the body, but you better e afraid of God who can not only kill your body any time he wants to, but he can send both your body and soul to hell.
Matthew 10:29 Are not two sparrows sold for a farthing? and one of them shall not fall on the ground without your Father.
or don't be foolish God loves even a little Sparrow that man only regards as valuable as a farthing, and knows when they are harmed.
Matthew 10:30 But the very hairs of your head are all numbered.
don't you know that God is aware even when you lose one of the hairs on your head.
Matthew 10:31 Fear ye not therefore, ye are of more value than many sparrows.
Don't be afraid of men remember that God values your life and soul a lot more than a whole lot of Sparrows.
Matthew 10:32 Whosoever therefore shall confess me before men, him will I confess also before my Father which is in heaven.
So if you go and preach the good news here , when we get to Heaven I'll tell the Father you were loyal to me but,
Matthew 10:33 But whosoever shall deny me before men, him will I also deny before my Father which is in heaven.
Just remember this if they scare you into not preaching the Gospel here on Earth, I won't save you from the wrath of God in Heaven.
Matthew 10:34 Think not that I am come to send peace on earth: I came not to send peace, but a sword.
After all I didn't come down from my comfortable existence in Heaven just to make everyone jolly, I came to show them how lost they were, and have them fight against the temptations of Satan.
Matthew 10:>35 For I am come to set a man at variance against his father, and the daughter against her mother, and the daughter in law against her mother in law.
And the people you will have the worst time with will be your own relatives.
Matthew 10:36 And a man's foes shall be they of his own household.
These are the ones who are going to be the ones who hamper you the most.
Matthew 10:37 He that loveth father or mother more than me is not worthy of me: and he that loveth son or daughter more than me is not worthy of me.
But if you listen to them and ignore me because you care so much for them and less about me, you are not worth my effort to save you so you can spend eternity in Heaven.
Matthew 10:38 And he that taketh not his cross, and followeth after me, is not worthy of me.
And if you don't go out there and preach the Gospel and do as I have done for you, you aren't worthy to be my disciple.
Matthew 10:39 He that findeth his life shall lose it: and he that loseth his life for my sake shall find it.
And finally he says so what if they kill you for preaching repentance for sin, all you will lose is your physical life, and in return you will gain eternal life.
I Hope this helps.