The purpose of a full node in Bitcoin is to independently verify the consensus rules for transactions and blocks. This means your node will check every transaction and every block before accepting it as part of the heaviest chain.
Miners decide which transactions to include in a block and then full nodes check that those transactions are valid transactions before accepting the block.
From the point of view of a Bitcoin full node, there is no such thing as an "illegal transaction." There are only valid transactions and invalid transactions. Furthermore, since Bitcoin is a global network, it doesn't really make sense to talk about transactions being legal or illegal since these are local, jurisdictional concepts. For example, what is considered illegal in one country might be perfectly legal in another country. If miners in a certain jurisdiction decide to not mine a particular transaction due to a local restriction, this does not prevent miners in a different jurisdiction from mining the transaction.