The thalamus  is a midline symmetrical structure in the brains of vertebrates. It is between the cerebral cortex and midbrain.

It relays sensory and motor signals to the cerebral cortex, and regulates consciousness, sleep, and alertness.

The thalamus sits above the hypothalamus, and below the cerebral cortex. It is a collection of nuclei with various functions. It acts as a relay station, gathering sense information of all kinds (except olfactory) and passes it on to the cerebral cortex.

There are action systems for several types of behaviour, including eating, drinking, defecation, and copulation. These behaviours satisfy short-term needs, and are called 'consummatory' behaviours.

Main functions 
The thalamus has many functions. First of all, it acts as a relay station, or hub. It relays information between subcortical areas and the cerebral cortex. In particular, every sensory system except smelling has a thalamic nucleus that receives sensory signals and sends them to the related  areas in the cortex.  For example, for sight, inputs from the retina are sent to the thalamus, which in turn sends them to the visual cortex in the occipital lobe.

The thalamus is believed to process sensory information as well as to relay it: each of the main sensory relay areas gets strong feedback from the cerebral cortex. 

The thalamus also plays an important role in regulating states of sleep and wakefulness. Thalamic nuclei have strong connections with the cerebral cortex. These circuits are believed to be involved with consciousness. The thalamus plays a major role in regulating arousal, the level of awareness, and activity. Damage to the thalamus can lead to permanent coma.

The thalamus has a role in the  basal ganglia system  but this is poorly understood. The thalamus has been thought of as a "relay" that just forwards signals to the cerebral cortex. But research suggests that thalamus is more selective. Many different functions are linked to regions of the thalamus. This is the case for most sensory systems (except the olfactory system), such as the auditory, somatic sensory system, visceral, eating and visual systems. There specific lesions cause specific sensory deficits. A big role of the thalamus is to support the motor and language systems. Much of the circuitry for these systems is shared with the thalamus. The thalamus is functionally connected to the hippocampus. This is part of the hippocampal system which is crucial for human episodic event memory.

The information for motor control is a network involving the thalamus as a subcortical motor center. In the brains of primates, the thalamus provides the specific channels from the basal ganglia and cerebellum to the cortical motor areas. In an investigation of the eye movement motor response in three monkeys, the thalamic regions were found to cause antisaccade eye-movement. That is the ability to inhibit the reflexive jerking movement of the eyes in the direction of a presented stimulus. They still look in the direction of the stimulus, but do so in a more controlled manner.

Recent research suggests that the mediodorsal (MD) thalamus may "amplify the connectivity (signaling strength) of just the circuits in the cortex needed for the current context. This helps the flexibility (of the mammalian brain) to make complex decisions by wiring the many associations on which decisions depend into weakly connected cortical circuits". Researchers founds that "enhancing MD activity magnified the ability of mice to "think". This lowered by more than 25 percent their error rate in deciding which conflicting sensory stimuli to follow to find the reward".

In short, the thalamus helps to make mammals more effective at making decisions and living in their natural environment.

The half-second delay 
The thalamus is a key area which is involved in what is known as the "half-second delay". This is a perceptual illusion which has only recently been discovered. The discovery is as follows: we perceive events in the world as instantaneous. They happen when we see (hear, sense) them happening. But the processing of visual signals at least is what the thalamus does. Experientially, we see events happening (so we think) without any delay. But in reality it takes half a second for the brain to organise the data which comes in from, let us say, vision. But we do not sense that half-second delay at all. Our perception of events is that we see them as they happen.

All this applies to consciousness and conscious behaviour. Automatic responses to sudden pain happen instantaneously (bare foot on a pin for example). But they are consciously perceived later.

References 

Anatomy of the brain
Neuroscience