I know that syntax deals with the ways words are put together to form phrases and sentences, I would like to know how does it relate to linguistics more broadly.
The way syntax interacts with the other components of a linguistic theory depends on the linguistic theory one adheres to. Meaning-text theory, while not being a theory I use often in my work, gives an interesting point of view on where specific "fields" of linguistics fit with respect to each other. This is because it strives to build a complete and consistent model of how language works in translating any given meaning in a corresponding "text".
To put it in a nutshell, meaning has a very free structure but also a very high dimensionality. We express it with strings of "sounds", or of letters, which are basically one-dimension entities, and must therefore have a much more rigid structure if they are to encode the information wholly.
Meaning-text theory proposes models with various levels of representation:
They are actually more numerous than shown in this image, but this gives the general idea. To move from one level of representation to the next, you use "components" which, transforming dependencies, create structure and remove dimensionality.
From this point of view, the syntactic component is the one that transforms semantic dependencies into syntactic dependencies. In doing this, it may for instance merge many semantemes (meaning units) into one lexeme (lexical unit), or split one semanteme into many lexemes. It also starts defining a word order for the sentence—in generative formalisms, the word order is usually fixed at the syntactic level, but this may not be entirely true in dependency formalisms. From the representation point of view, it turns a directed graph, first into a directed acyclic graph (deep syntax), then into a tree (surface syntax). This tree is then picked by the morphological component, which translates it into a "unary tree", basically a string.
You have to remember that all the branches of linguistics are related merely by the fact that they each concern something that shows up in our every utterance. "I eat daisies in the Springtime," uttered by a native speaker, has phonological, morpho-syntactic, and semantic information, and the utterance and its communicative intent and context can be described in terms of pragmatics. // If you think of language as having three broad areas, form, content, and use, you've got phonology & morpho-syntax under "form," semantics under "content," and pragmatics under "use." –
To place syntax in a more general context, many use some version of Charles Morris's taxonomy of the general theory of signs, Morris, Charles (1938), Foundations of the Theory of Signs (Chicago: University of Chicago Press). My version of it is partly due to what Richmond Thomason says about it in his logic text, and partly due to what McCawley says about grammar in his text.
A language, or sign system, concerns the signs themselves, the significance of the signs in the world, the people who use the signs. The study of what signs and combinations of them are part of a language is morphology, according to Thomason, but grammar according to McCawley. Following linguistic tradition, morphology has a different sense -- the structure of words -- so with McCawley, I use grammar for this.
The study of the relations of signs to one another is syntax, including the study of implication, which is logical syntax. This is how McCawley uses the term.
The study of the relation between signs and the world is semantics. This is generally how logicians and philosophers use this term, at least in principle, but linguists usually use semantics to mean some sort of syntax.
The study of how people use the signs in reference to things in the world is pragmatics.
Using the terms in this way, I would say that the original question is actually about grammar rather than syntax.
In usage by linguists, the terms grammar and syntax are extremely fluid.
My own main interest is in grammar, but in contrast, McCawley arrived at the view that grammar is both uninteresting and undoable (these are my words, though, not his).
Linguistics is an extremely broad field, encompassing aspects of sociology, physiology, psychology, computer science, law, education etc. etc. and the structure of languages. E.g. English has certain properties, Chinese has others, and Swahili has yet others. The study of the structure of languages (generally, or individually) at a single time -- like, English as spoken now, by me, or by you, is the study of the grammar of a language. It is obvious that we have words (it may be hard to tell in some cases whether you have one word or two, but it's not hard to tell that there is a word "person" or a word "kill" or a word "snake").
The study of how words can be arranged into utterances is the domain of syntax. For instance, in English you can say "The children see the man" and not *"See the children the man", though in some languages you can say that (sometimes only that, somtimes, that as well"). Syntax is related to the field of morphology in that the words "kill", "kills", "killed" and "killing" are related words, and you have to pick the right word form in constructing a sentence like "The snake ___ people", inserting a form of "kill" (kills, not kill or killing).
Morphology is related to phonology, in that phonology takes simple and invariant parts of words and modifies the pronunciation, for example the past tense is pronounced [t] in "slapped", as [d] in "scrubbed" and as [ɨd] in "wetted" – there are rules that change the suffix /-d/ supplied by the morphology so that it's pronounced [t] or [ɨd], depending on the context. Phonetics then provides more precise specifications of the physical implementation of individual sounds. Semantics, on the other hand (getting back to syntax) specifies the relationship between the meaning of an utterance and the words, morphemes, and syntactic structures that you use. The division between pragmatics and semantics is subtle and contentious, and you need to ask a separate question about that, if you care.
There are also relationships between semantics and morphology (morphemes often have a particular semantic function), semantics and phonology (there are, occasionally, phonological rules that are sensitive to semantic properties), phonology and syntax, and so on.